#include "mathutils.h"

#include <stdlib.h>

#include "systemutils.h"

unsigned randomInt() {
    return rand();
}

unsigned randomIntWithMax(unsigned max) {
    return rand() % max;
}

int randomIntIn(int min, int max) {
    if (min > max) 
        swapInt(&min, &max);
    return (rand() % (max - min)) + min;
}

double random() {
    return rand() / (RAND_MAX + 1.0);
}

void swapInt(int *a, int *b) {
    int c = *a;
    *a = *b;
    *b = c;
}

void seedRandomWithTime() {
    srand((unsigned) currentTimeMillis());
}